home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Source / loTeX / loTeX.app / Theory < prev    next >
Encoding:
Text File  |  1992-07-24  |  1.2 KB  |  30 lines

  1. /* Algorithm:
  2.  * We keep a count called "changed"; initially, "changed=0".
  3.  * We also keep three timers, called "busy", "sleeping", and "running."
  4.  * Initially none of them are running.
  5.  * (We set these to zero when they're not supposed to be running.  
  6.  * If we're told that one has gone off, we check that it's not zero.)
  7.  * If "busy" is running, we "are busy."
  8.  * If "sleeping" is running, we "are asleep."
  9.  * If "running" is running, we "are running."
  10.  * So much for the state.  5 things can happen: 1: keystroke, 2: tex is done,
  11.  * 3: running times out, 4: busy times out, 5: sleeping times out.
  12.  *
  13.  * When user types:
  14.  *    If the text is empty, we set "changed" to 0.
  15.  *    If it's not empty, we set "changed" to 2.
  16.  *    If we are running or we are asleep, that's all.
  17.  *    Otherwise:
  18.  *     if we are busy we stop "busy".
  19.  *     Then we start "busy."
  20.  * If "busy" times out:
  21.  *    We stop "busy".
  22.  *    If we are not "running" and not "sleeping" and "changed" we start TeX.
  23.  * When we start TeX, we decrement "changed" and start "running"
  24.  * If "running" goes off, we kill TeX (and thus TeX stops).
  25.  * When TeX stops, we stop "running".
  26.  *    If "changed", we start "sleeping".
  27.  * If "sleeping" goes off, we stop "sleeping."
  28.  *    Then if changed > 0 we start TeX. 
  29.  */
  30.